package com.zhentao.filter;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.CrossOrigin;

@Configuration
@CrossOrigin(origins = "*")
public class GatewayRoutes {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                .route("user_route", r -> r.path("/user/**")
                        .uri("http://localhost:8081"))
                .route("teacher", r -> r.path("/teacher/**")
                        .uri("http://localhost:8001"))
                .route("point", r -> r.path("/point/**")
                        .uri("http://localhost:8002"))
                .build();

    }

}
